package com.market.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.market.sys.entity.Notification;
import com.market.sys.mapper.NotificationMapper;
import com.market.sys.service.INotificationService;
import com.market.sys.util.TimeUtil;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xd
 * @since 2024-03-26
 */
@Service
public class NotificationServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements INotificationService {

    @Override
    public void createNotification(String title, String content, Integer userId, Integer senderId, Integer relatedId, String relatedType, Integer state) {
        Notification notification = new Notification();
        notification.setContent(content);
        notification.setTitle(title);
        notification.setNotifiedAt(TimeUtil.timeYmdhms(new Date()));
        notification.setRelatedId(relatedId);
        notification.setRelatedType(relatedType);
        notification.setUserId(userId);
        notification.setSenderId(senderId);
        notification.setState(state);
        save(notification);
    }
}
